package com.zh.elec.web.actions;

import java.util.List;

import com.zh.elec.model.FactoryAddress;
import com.zh.elec.service.FactoryAddressService;
import com.zh.elec.web.actions.base.AbstractAction;

/**
 * 产地
 * @author scy
 *
 */
public class FactoryAddressAction extends AbstractAction {

	/**
	 * 
	 */
	private static final long serialVersionUID = 502279211404367071L;
	private FactoryAddressService factoryAddressService;
	private FactoryAddress factoryAddress;
	private List<FactoryAddress> list;
	
	/**
	 * 添加
	 * @return
	 */
	public String save(){
		if(factoryAddress != null){
			factoryAddress = (FactoryAddress)factoryAddressService.save(factoryAddress);
			return "success";
		}
		return "add";
	}
	/**
	 * 修改
	 * @return
	 */
	public String update(){
		factoryAddress = (FactoryAddress)factoryAddressService.update(factoryAddress);
		return "success";
	}
	/**
	 * 删除
	 * @return
	 */
	public String del(){
		factoryAddress = (FactoryAddress)factoryAddressService.del(factoryAddress);
		return "success";
	}
	/**
	 * 查询
	 * @return
	 */
	public String find(){
//		String companyName="";
//		String companyAddress="";
		
//		if(companyName != null && !companyName.isEmpty() || companyAddress != null && !companyAddress.isEmpty()){
//			String hql = "";
			list = factoryAddressService.findAll();
//		}
		return "success";
	}
	/**
	 * 根据name查询
	 * @return
	 */
	public String findByName(){
		String name = "";
		String value= "";
		List<FactoryAddress> list = factoryAddressService.findByName(name, value);
		System.out.println(list.size());
		return "success";
	}
	
	
	public FactoryAddress getFactoryAddress() {
		return factoryAddress;
	}
	public void setFactoryAddress(FactoryAddress factoryAddress) {
		this.factoryAddress = factoryAddress;
	}
	public void setFactoryAddressService(FactoryAddressService factoryAddressService) {
		this.factoryAddressService = factoryAddressService;
	}
	public List<FactoryAddress> getList() {
		return list;
	}
	public void setList(List<FactoryAddress> list) {
		this.list = list;
	}
}
